package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServicePhonecode;
import com.ruoyi.service.service.IServicePhonecodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手机验证码表Controller
 * 
 * @author ZDL
 * @date 2025-03-17
 */
@RestController
@RequestMapping("/service/phonecode")
public class ServicePhonecodeController extends BaseController
{
    @Autowired
    private IServicePhonecodeService servicePhonecodeService;

    /**
     * 查询手机验证码表列表
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServicePhonecode servicePhonecode)
    {
        startPage();
        List<ServicePhonecode> list = servicePhonecodeService.selectServicePhonecodeList(servicePhonecode);
        return getDataTable(list);
    }

    /**
     * 导出手机验证码表列表
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:export')")
    @Log(title = "手机验证码表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServicePhonecode servicePhonecode)
    {
        List<ServicePhonecode> list = servicePhonecodeService.selectServicePhonecodeList(servicePhonecode);
        ExcelUtil<ServicePhonecode> util = new ExcelUtil<ServicePhonecode>(ServicePhonecode.class);
        util.exportExcel(response, list, "手机验证码表数据");
    }

    /**
     * 获取手机验证码表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:query')")
    @GetMapping(value = "/{phonecodeId}")
    public AjaxResult getInfo(@PathVariable("phonecodeId") Long phonecodeId)
    {
        return success(servicePhonecodeService.selectServicePhonecodeByPhonecodeId(phonecodeId));
    }

    /**
     * 新增手机验证码表
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:add')")
    @Log(title = "手机验证码表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServicePhonecode servicePhonecode)
    {
        return toAjax(servicePhonecodeService.insertServicePhonecode(servicePhonecode));
    }

    /**
     * 修改手机验证码表
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:edit')")
    @Log(title = "手机验证码表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServicePhonecode servicePhonecode)
    {
        return toAjax(servicePhonecodeService.updateServicePhonecode(servicePhonecode));
    }

    /**
     * 删除手机验证码表
     */
    @PreAuthorize("@ss.hasPermi('service:phonecode:remove')")
    @Log(title = "手机验证码表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{phonecodeIds}")
    public AjaxResult remove(@PathVariable Long[] phonecodeIds)
    {
        return toAjax(servicePhonecodeService.deleteServicePhonecodeByPhonecodeIds(phonecodeIds));
    }
}
